import React, { memo } from 'react';
import { AbsentList } from '@/pages/OnboardAndLeave/LeaveManagement/Talk/containers';
import styles from './index.less';
import TalkConclusion from './TalkConclusion';
import TalkSuggest from './TalkSuggest';

const getTitle = ({ value = {}, title }) => {
    const { interviewTitle } = value;
    return (
        <>
            <span>{title || interviewTitle || '--'}</span>
        </>
    );
};

const TalkResult = props => {
    const {
        data = {},
        conclusionStatus,
        extendTop = null,
        extendBottom = null,
        onlyConclusionWhenAgree = false,
        ...rest
    } = props;
    return (
        <div className={styles.interviewTotalEvaluateResults}>
            <div className={styles.resultWrap}>
                <div className={styles.resultTitle}>
                    {getTitle({
                        value: data.interviewArrangeVO,
                        ...rest
                    })}
                </div>
                <>
                    {extendTop}
                    <TalkConclusion
                        data={data?.interviewArrangeVO}
                        conclusionStatus={conclusionStatus}
                    />
                    {
                        !onlyConclusionWhenAgree && <TalkSuggest
                            dataSource={{
                                interviewArrangeVO: data.interviewArrangeVO,
                                interviewRecordInfoVOList: data.interviewRecordInfoVOList
                            }}
                        />
                    }
                    {
                        !!data?.absentList?.length &&
                        !onlyConclusionWhenAgree &&
                        <AbsentList dataSource={data?.absentList} />
                    }
                    {extendBottom}
                </>
            </div>
        </div>
    );
};

export default memo(TalkResult);
